<?php
namespace app\home\controller;
use \think\Db;


class Index extends \think\Controller
{
    public function index(){ 
        //拍品种类
        $classArr = Db('baode_goods_category')->select();
       
        //线上展览
        input('category_id') and $categoryId = input('category_id') or $categoryId = 1;
        $where1 = 'status = 1 and category_id = '.intval($categoryId);
        $goodsArr = Db('baode_goods')->where($where1)->order('is_hot asc ,id desc')->limit(8)->select();
        
        
        
        
        
        //成交记录
        input('category_id') and $categoryId = input('category_id') or $categoryId = 1;
        $where2 = 'status = 2  and category_id = '.intval($categoryId);
        $saleArr = Db('baode_goods')->where($where2)->order('is_hot asc ,id desc')->limit(8)->select();
        
        //专家团队
        $zjArr = Db('baode_expert')->limit(4)->select();
        
        //拍卖资讯
        $cArr = Db('baode_article_category')->where('pid', 2)->select();
        $ids = array_column($cArr, 'id');
        $where3 = 'is_show = 1 and category_id in ('.implode(',', $ids).')';
        $zxArr = Db('baode_article')->where($where3)->order('is_top asc ,id desc')->limit(5)->select();
        
        
        //公司简介
        $sjArr = Db('baode_article')->where('category_id', 10)->find();
        
        //友情链接
        $linkArr = Db('baode_links')->where('status', 1)->order('id desc')->limit(10)->select();
        return $this->allFetch(get_defined_vars());
    }
    
    public function order(){
       if(input('sbt')){
           (!input('tel') ||  !input('username') ||  !input('mark')) and echojson("fail", '2');
           $data['names'] = input('username');
           $data['telephone'] = input('tel');
           $data['content'] = htmlspecialchars(input('mark'));
           $data['type'] = 2;
           $data['on_time'] = time();
           Db('baode_message')->insert($data);
           echojson('ok', '1');
       }
        return $this->allFetch(get_defined_vars());
    }
    
    
    
    
    
}
